<template>
    <div>
        <el-col :span="24">
     
      <el-menu
        active-text-color="#409eff"
        background-color="#304156"
        :collapse="isCollapse"
        class="el-menu-vertical-demo"
        default-active="2"
        text-color="#fff"
        unique-opened
        router
        @open="handleOpen"
        @close="handleClose"
      >
        <el-menu-item index="/home">
          <el-icon><HomeFilled /></el-icon>
          <span>首页</span>
        </el-menu-item>
        <el-sub-menu :index="'/'+item.name" v-for="item in menus" :key="item.id">
          <template #title>
            <el-icon><QuestionFilled /></el-icon>
            <span>{{ item.title }}</span>
          </template>
            <el-menu-item :index="'/'+item.name+'/'+item1.name" v-for="item1 in item.children" :key="item1.id"><el-icon><HomeFilled /></el-icon>{{ item1.title }}</el-menu-item>
        </el-sub-menu>
      
      </el-menu>
    </el-col>
    </div>
</template>

<script setup lang="ts">
import {useStore} from "../../../store/user"
import { ref } from 'vue'
import {UserInfoAPI }from "../../../http/api/index"
    import {
    QuestionFilled,
    Document,
    List,
    Goods,
    HomeFilled,
    HelpFilled,
    Menu as IconMenu,
    Location,
    Setting,
    } from '@element-plus/icons-vue'

    // UserInfoAPI().then((res)=>{
    //   console.log("res",res);
    //   if(res.code===0){

    //   }
      
    // })
    const store =useStore()

    let menus = store.myrouterdata
    // console.log("menus",menus);
    
    const isCollapse = ref(false)
    const handleOpen = (key: string, keyPath: string[]) => {
    console.log(key, keyPath)
    }
    const handleClose = (key: string, keyPath: string[]) => {
    console.log(key, keyPath)
    }
</script>

<style scoped lang="less">
    .el-menu-vertical-demo:not(.el-menu--collapse) {
    width: 200px;
    min-height: 400px;
    }
</style>